package com.production.CoursePlatform.service;

import com.production.CoursePlatform.entity.AssignHomework;
import com.production.CoursePlatform.mapper.AssignHomeworkMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AssignHomeworkService {
    @Autowired
    private AssignHomeworkMapper assignHomeworkMapper;

    // 创建新的作业
    public int createAssignHomework(AssignHomework assignHomework) {
        return assignHomeworkMapper.insertWithoutAhID(assignHomework);
    }

    // 通过 ctID 查找作业
    public List<AssignHomework> findByCtID(int ctID) {
        return assignHomeworkMapper.selectByCtID(ctID);
    }

    // 通过 ahID 删除作业
    public int deleteAssignHomework(int ahID) {
        return assignHomeworkMapper.deleteByAhID(ahID);
    }

    // 更新作业信息
    public int updateAssignHomework(AssignHomework assignHomework) {
        return assignHomeworkMapper.updateAssignHomework(assignHomework);
    }
}

